package com.ruoyi.system.service.impl;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.HcMainOrder;
import com.ruoyi.system.domain.HcPtInfo;
import com.ruoyi.system.domain.HcPtInfoResult;
import com.ruoyi.system.mapper.HcMainOrderDataMapper;
import com.ruoyi.system.service.HcMainOrderDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@DataSource(value = DataSourceType.SLAVE)
public class HcMainOrderDataServiceImpl implements HcMainOrderDataService
{
    @Autowired
    private HcMainOrderDataMapper hcMainOrderMapper;

    /**
     * 查询
     *
     * @param id 【项目】主键
     * @return 【项目】
     */
    @Override
    public Map selectHcOrderInfo(Integer id)
    {
        Map returnMap = new HashMap();
        HcMainOrder hcMainOrder=hcMainOrderMapper.selectMainOrderById(id);
        //基础信息
        Map detailBasic = new HashMap();
        detailBasic.put("deptName",hcMainOrder.getDeptName());//所属医院
        detailBasic.put("sampleCaseId",hcMainOrder.getSampleCaseId());//病历号
        detailBasic.put("patientName",hcMainOrder.getPatientName());//受检者姓名
        detailBasic.put("patientPhone",hcMainOrder.getPatientPhone());//受检者电话
        detailBasic.put("patientSex",hcMainOrder.getPatientSex());//受检者性别
        detailBasic.put("patientAge",hcMainOrder.getPatientAge());//受检者年龄
        detailBasic.put("otherName",hcMainOrder.getOtherName());//配偶姓名
        detailBasic.put("otherPhone",hcMainOrder.getOtherPhone());//配偶电话
        detailBasic.put("otherSex",hcMainOrder.getOtherSex());//配偶性别
        detailBasic.put("otherAge",hcMainOrder.getOtherAge());//配偶年龄
        detailBasic.put("patientKaryotype",hcMainOrder.getPatientKaryotype());//受检人核型
        detailBasic.put("otherKaryotype",hcMainOrder.getOtherKaryotype());//配偶核型
        returnMap.put("detailBasic",detailBasic);

        //支付信息
        Map payInfo = new HashMap();
        payInfo.put("isPublic",hcMainOrder.getIsPublic());//结算方式
        payInfo.put("num",hcMainOrder.getNum());//计价数量
        payInfo.put("price",hcMainOrder.getPrice());//单价
        payInfo.put("amount",hcMainOrder.getWholeAmount());//总金额
        payInfo.put("payDate",hcMainOrder.getPayDate());//支付日期
        payInfo.put("paytradeId",hcMainOrder.getPaytradeId());//交易流水号
        payInfo.put("payRelationship",hcMainOrder.getPayRelationship());//付款人关系
        returnMap.put("payInfo",payInfo);

        //产品信息
        Map productInfo = new HashMap();
        productInfo.put("submissionCode",hcMainOrder.getSubmissionCode());//送检码
        productInfo.put("itemName",hcMainOrder.getItemName());//检测项目
        productInfo.put("reportSchedule",hcMainOrder.getReportSchedule());//检测进度
        productInfo.put("expectDate",hcMainOrder.getExpectDate());//预出报告日期
        productInfo.put("reportDate",hcMainOrder.getReportDate());//支付日期
        productInfo.put("reportUrl",hcMainOrder.getReportUrl());//报告地址
        productInfo.put("receiveReportAddress",hcMainOrder.getReceiveReportAddress());//接收报告地址
        returnMap.put("productInfo",productInfo);

        //样本信息
        List<HcPtInfo> ptInfoList=hcMainOrderMapper.selectPtInfoListByMainId(id);
        returnMap.put("sampleInfo",ptInfoList);

        //样本结果
        List<HcPtInfoResult> ptInfoResultList=hcMainOrderMapper.selectPtInfoResultListByMainId(id);
        returnMap.put("sampleResult",ptInfoResultList);

        return returnMap;
    }

    /**
     * 查询【项目】列表
     *
     * @param HcMainOrder 【项目】
     * @return 【项目】
     */
    @Override
    public List<HcMainOrder> selectHcMainOrderDataList(HcMainOrder HcMainOrder)
    {
        return hcMainOrderMapper.selectMainOrderList(HcMainOrder);
    }

}
